518. 零钱兑换 II
为保证权益,题目请参考 518. 零钱兑换 II(From LeetCode).
解决方案1
Python
python
from typing import List
class Solution:
def change(self, amount: int, coins: List[int]) -> int:
dp = [0 for i in range(amount+1)]
for coin in coins:
for i in range(coin, amount+1):
dp[i] += dp[i-coin] + 1
return dp[amount]
if __name__ == "__main__":
so = Solution()
print(so.change(5, [1, 2, 5]))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16